<!--检测任务-列表页面-->
<template>
	<view class="content_view">
		<u-navbar title-color="#FFFFFF" height="48" back-icon-color="#FFFFFF" :border-bottom="false" :is-fixed="true" title="检测任务列表"></u-navbar>
		<uc-content :loading="loading">
			<view v-if="inMaintenanceList.length<1" class="view-center">
				<u-empty text="暂无检测任务数据信息" mode="list"></u-empty>
			</view>
			<view v-else>
				<view class="list-item" v-for="(item,index) in inMaintenanceList" :key="index" @click="checkItem(item)">
					<view class="list-top">
						<view class="list-left">任务:{{ item.taskName }}</view>
					</view>
					<view class="list-center">
						<view class="list-right">业主企业:{{ item.enterpriseName }}</view>
						<view class="list-right">检测企业:{{ item.examineName }}</view>
						<view class="list-right">执行时间:{{item.examineDate}}月</view>
						<view class="list-right">当前状态:{{statusFormat(item.examineStatus)}}</view>
					</view>
				</view>
			</view>
			<u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" />
		</uc-content>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loading: false,
				inMaintenanceList: [],
				statusOptions: [],
				pageNum: 0,
				finished: false,
				status: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '没有更多数据了'
				},
				scrollTop: 0,
				// taskId:'',
			}
		},
		methods: {
			statusFormat(data) {
				return this.selectDictLabel(this.statusOptions, data);
			},
			checkItem(item) {
				uni.navigateTo({
					url: '/pages/testing/info?ucId=' + item.ucId,
				});
			},

			onPageScroll(e) {
				this.scrollTop = e.scrollTop;
			},
			onShow() {
				this.initView()
			},
			initView() {
				this.loading = true
				this.inMaintenanceList = []
				this.pageNum = 0
				this.getInExamineTaskPage()
				this.getDicts("examine_status").then(response => {
				    this.statusOptions = response.data.data;
				});
			},
			//获取维保工单分页信息数据
			getInExamineTaskPage() {
				this.pageNum++
				let _this = this
				return new Promise((resolve, reject) => {
					_this.utils.request("/api/app/examine/getInExamineTaskPage", {
						pageNum: this.pageNum,
						pageSize: 10
					}, "post", "app", true).then(res => {
						console.log(res)
						_this.inMaintenanceList.push(...res.data.list)
						_this.finished = (res.data.pageNum >= res.data.pages);
						if (_this.finished) {
							_this.status = 'nomore';
						}
						this.loading = false
						resolve(res)
					}).catch(error => {
						this.loading = false
						reject(error)
					})
				})
			},
			onReachBottom() {
				if (this.finished) return;
				this.status = 'loading';
				this.getInExamineTaskPage().then(res => {
					if (this.finished) this.status = 'nomore';
					else this.status = 'loading';
				}).catch(error => {
					this.loading = false
					this.status = 'nomore';
				})
			}
		}
	}
</script>


<style lang="scss" scoped>
	@import "@/uview-ui/libs/css/style.components.scss";

	.list-item {
		padding: 30rpx 40rpx;
		background-color: #fff;
		border-bottom: #999999 1px solid;

		.list-top {
			@include vue-flex;
			justify-content: space-between;
			align-items: center;

			.list-left {
				font-weight: bold;
				font-size: 30rpx;
			}

			.list-right {
				font-size: 30rpx;
				line-height: 34rpx;
				color: #999999;
			}
		}

		.list-center {
			margin-top: 20rpx;
			font-size: 28rpx;
			color: #999999;
		}

		.list-bottom {
			display: flex;
			margin-top: 20rpx;
			font-size: 28rpx;
			justify-content: space-between;
			color: #999999;
		}
	}
</style>

